# estimate regression parameters
# 
# Author: guochun
###############################################################################


agModeling.poissonM=function(modelingObject){
	data.ppp=populationToppp(modelingObject@population)
	re=ppm(data.ppp,modelingObject@formu,
			covariates=modelingObject@covr)
	lambda=new("parameter",name="lambda",value=exp(re$coef[1]))
	paras=list("lambda"=lambda)
	ncovr=length(modelingObject@covr)
	if(ncovr>0){
		pnames=names(modelingObject@covr)
		for(i in 1:ncovr)
		paras=c(paras,new("parameter",name=pnames[i],value=re$coef[i+1]))
	   names(paras)=c("lambda",pnames)
	}
	
	if(modelingObject@pvalue){
		#???
	}
	
	modelingObject@parameters=paras
	attr(modelingObject,"re.ppm")=re
	attr(modelingObject,"data.ppp")=data.ppp
	return(modelingObject)
}
